VERSION 5.00
Begin VB.UserControl Lista 
   BackColor       =   &H80000013&
   ClientHeight    =   2280
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   2205
   ScaleHeight     =   2280
   ScaleWidth      =   2205
   Begin VB.CheckBox chkTodos 
      BackColor       =   &H80000013&
      Caption         =   "Todos"
      Height          =   255
      Left            =   1320
      TabIndex        =   1
      Top             =   2040
      Width           =   855
   End
   Begin VB.ListBox List1 
      Height          =   2010
      Left            =   0
      MultiSelect     =   1  'Simple
      TabIndex        =   0
      Top             =   0
      Width           =   2175
   End
End
Attribute VB_Name = "Lista"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim cod As String

Private Sub chkTodos_Click()
If chkTodos.Value = 1 Then
    b = True
Else
    b = False
End If
For i = 0 To List1.ListCount - 1
    List1.Selected(i) = b
    Next i
   
End Sub

Public Sub inicializar(sql As String)

ConsultaSql sql

If rs.RecordCount <> 0 Then
    rs.MoveFirst
    Do While Not rs.EOF
        List1.AddItem Trim(rs.Fields(1).Value)
        List1.ItemData(List1.NewIndex) = Trim(rs.Fields(0).Value)
        rs.MoveNext
    Loop
    
End If
chkTodos.Value = 1
End Sub

Public Function codigos() As String
cod = " ( "
For i = 0 To List1.ListCount - 1

    If List1.Selected(i) = True Then
        If cod = " ( " Then
            cod = cod & Str(List1.ItemData(i))
        Else
            cod = cod & "," & Str(List1.ItemData(i))
        End If
    End If
Next i
    
cod = cod & " ) "
codigos = cod
End Function
